package com.yjht.online.arg.reslove.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.yjht.online.arg.ArgParam;
import com.yjht.online.arg.excption.ArgError;
import com.yjht.online.arg.reslove.ArgResloveByKey;

import java.util.List;

public class PersonInfoReslove implements ArgResloveByKey {

    final String orgParam = "person";

    @Override
    public boolean support(String key) {
        return orgParam.equals(key);
    }

    @Override
    public void resolve(ArgParam argParam, String key, List<String> value) throws ArgError {
        if (CollectionUtil.isEmpty(value)) {
            throw new ArgError("参数错误");
        }
        if (value.size() > 1) {
            throw new ArgError("参数错误");
        }
        argParam.setPersonFilePath(value.get(0));
    }

}
